﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;

using Ths.Framework;
using Ths.Components.Common;
using Ths.Components.Dictionary;
using Ths.Components.Dictionary.Entity;
//using TestLuoQingHua.Data.CommonData;
using SafetyRecordData.Data.DAL;
using System.Data.OleDb;
using qiupeng.Public;

public partial class Search_UserMessagesDetail : Base
{
    #region 属性
    
    /// <summary>
    /// 是否是添加
    /// </summary>
    public bool IsNew
    {
        get
        {
            if (ViewState["IsNew"] != null)
                return Convert.ToBoolean(ViewState["IsNew"]);
            else
                return GetRequestStr("isnew") != string.Empty;
        }

        set
        {
            ViewState["IsNew"] = value;
        }

    }

    /// <summary>
    /// 是否是浏览
    /// </summary>
    public bool IsView
    {
        get
        {
            return GetRequestStr("view") != string.Empty;
        }

    }

    #endregion
    Db List = new Db();
    DASearch dal = new DASearch();
    public string XinagPian = "nothing.jpg";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            this.BindList();

            if (GetRequestStr("username") != "" && GetRequestStr("username") != null)
            {
                this.txtUserName.Text = GetRequestStr("username");
                string str = "select *,(select a.JgName as jgname from qp_hr_jigou a,qp_hr_JiGou b where a.id=b.ParentNodesID and b.id=c.YinPinBMId) as danweiname from qp_hr_Staff c where ltrim(rtrim(xingming))='" + this.List.GetFormatStr(Server.UrlDecode(this.txtUserName.Text)) + "'";
                OleDbDataReader reader = this.List.GetList(str);
                if (reader.Read())
                {
                    this.GongHao.Text = reader["GongHao"].ToString();
                    this.XingMing.Text = reader["XingMing"].ToString();
                    this.XingBie.Text = reader["XingBie"].ToString();
                    this.HunYin.Text = reader["HunYin"].ToString();
                    this.ChuSheng.Text = DateTime.Parse(reader["ChuSheng"].ToString()).ToShortDateString();
                    this.JiGuan.Text = reader["JiGuan"].ToString();
                    this.MinZhu.Text = reader["MinZhu"].ToString();
                    this.ZhengZhi.Text = reader["ZhengZhi"].ToString();
                    this.ShenFen.Text = reader["ShenFen"].ToString();
                    this.lblzhiweileibie.Text = reader["zhiweileibie"].ToString();
                    this.lblYinPinBM.Text = reader["YinPinBM"].ToString();
                    this.lbldanweiname.Text = reader["danweiname"].ToString();
                }
                reader.Close();

                this.HurtMessage();
                this.SanWeiMessage();
                this.PraiseMessage();
                this.PublishMessage();
            }
        }
    }


    public void HurtMessage()
    {
        string str = "";
        str += "";
        DataTable dt = dal.GetHurtMessage(this.GongHao.Text, GetRequestStr("starttime"), GetRequestStr("endtime"));
        if (dt.Rows.Count > 0)
        {
            str += "<table align='center' id='table1' bgcolor='#999999' border='0' cellpadding='4' cellspacing='1'";
            str += "width='100%'>";
            str += "<tr>";
            str += "<td align='center' bgcolor='#efefef' class='cpx12hei' colspan='7' width='33%' style='height: 21px'>";
            str += "<b>伤亡事故信息</b>";
            str += "</td>";
            str += "</tr>";
            str += "<tr style='color: #E7E7FF; background-color: #4A3C8C; font-weight: bold; white-space: nowrap;'>";
            str += "<th scope='col' style='color: DarkSlateGray; background-color: #94C3CE; white-space: nowrap;'>发生日期</th>";
            str += "<th align='center' scope='col' style='color: DarkSlateGray; background-color: #94C3CE; white-space: nowrap;'>伤害部位</th>";
            str += "<th align='center' scope='col' style='color: DarkSlateGray; background-color: #94C3CE; white-space: nowrap;'>伤害程度</th>";
            str += "<th align='center' scope='col' style='color: DarkSlateGray; background-color: #94C3CE;white-space: nowrap;'>事故类型</th>";
            str += "<th align='center' scope='col' style='color: DarkSlateGray; background-color: #94C3CE; white-space: nowrap;'>事故类别</th>";
            str += "<th scope='col' style='color: DarkSlateGray; background-color: #94C3CE; white-space: nowrap;'>处理文号</th>";
            str += "<th scope='col' style='color: DarkSlateGray; background-color: #94C3CE; white-space: nowrap;'>查处部门</th>";
            str += "</tr>";
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                str += "<tr style='color: Black; background-color: #FBFCFE;'>";
                str += "<td style='white-space: nowrap;'>" + Convert.ToDateTime( dt.Rows[0]["happentime"].ToString()).ToString("yyyy-MM-dd") + "</td>";
                str += "<td style='white-space: nowrap;'>" + new DAHurtDistress().GetBasicDataName(dt.Rows[0]["Hurtbody"].ToString().Trim().Replace("&nbsp;", ""), "7") +"</td>";
                str += "<td align='left' style='white-space: nowrap;'>" + new DAHurtDistress().GetBasicDataName(dt.Rows[0]["Leval"].ToString().Trim().Replace("&nbsp;", ""), "10") + "</td>";
                str += "<td align='left' style='white-space: nowrap;'>" +new DAHurtDistress().GetBasicDataName(dt.Rows[0]["Type"].ToString().Trim().Replace("&nbsp;", ""), "2") + "</td>";
                str += "<td style='white-space: nowrap;'>" + new DAHurtDistress().GetBasicDataName(dt.Rows[0]["Category"].ToString().Trim().Replace("&nbsp;", ""), "38")  + "</td>";
                str += "<td align='left' style='white-space: nowrap;'>" + dt.Rows[0]["Code"].ToString() + "</td>";
                str += "<td align='left' style='white-space: nowrap;'>" + dt.Rows[0]["Checkcompany"].ToString() + "</td>";
                str += "</tr>";
            }
            str += "</table>";
        }
        
        
       
        this.lblHurtMessage.Text = str;
    }

    public void SanWeiMessage()
    {
        string str = "";
        DataTable dt = dal.GetSanWeiMessage(this.GongHao.Text, GetRequestStr("starttime"), GetRequestStr("endtime"));
        if (dt.Rows.Count > 0)
        {
            str += "<table align='center' id='table2' bgcolor='#999999' border='0' cellpadding='4' cellspacing='1' width='100%'>";
            str += "<tr>";
            str += " <td align='center' bgcolor='#efefef' class='cpx12hei' colspan='6' width='33%' style='height: 21px'>";
            str += " <b>三违信息</b>";
            str += " </td>";
            str += " </tr>";
            str += "  <tr style='color: #E7E7FF; background-color: #4A3C8C; font-weight: bold; white-space: nowrap;'>";
            str += "  <th scope='col' style='color: DarkSlateGray; background-color: #94C3CE; white-space: nowrap;'>发生日期</th>";
            str += "   <th align='center' scope='col' style='color: DarkSlateGray; background-color: #94C3CE;white-space: nowrap;'>事故地点</th>";
            str += " <th align='center' scope='col' style='color: DarkSlateGray; background-color: #94C3CE;white-space: nowrap;'>处分</th>";
            str += "  <th align='center' scope='col' style='color: DarkSlateGray; background-color: #94C3CE; white-space: nowrap;'>罚款金额</th>";
            str += "  <th align='center' scope='col' style='color: DarkSlateGray; background-color: #94C3CE;white-space: nowrap;'>查处人</th>";
            str += "  <th scope='col' style='color: DarkSlateGray; background-color: #94C3CE; white-space: nowrap;'>查处部门</th>";
            str += " </tr>";
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                str += "  <tr style='color: Black; background-color: #FBFCFE;'>";
                str += " <td style='white-space: nowrap;'>" + Convert.ToDateTime(dt.Rows[0]["happentime"].ToString()).ToString("yyyy-MM-dd") + "</td>";
                str += " <td style='white-space: nowrap;'>" + dt.Rows[0]["Address"].ToString() + "</td>";
                str += " <td align='left' style='white-space: nowrap;'>" + dt.Rows[0]["Punish"].ToString() + "</td>";
                str += " <td align='left' style='white-space: nowrap;'>" + dt.Rows[0]["PunishMoney"].ToString() + "</td>";
                str += "  <td style='white-space: nowrap;'>" + dt.Rows[0]["Checkperson"].ToString() + "</td>";
                str += "  <td align='left' style='white-space: nowrap;'>" + dt.Rows[0]["Checkcompany"].ToString() + "</td>";
                str += " </tr>";
            }
            str += " </table>";
        }
        this.lblSanWeiMessage.Text = str;
    }

    public void PraiseMessage()
    {
        string str = "";
        DataTable dt = dal.GetPraiseMessage(this.GongHao.Text, GetRequestStr("starttime"), GetRequestStr("endtime"));
        if (dt.Rows.Count > 0)
        {
            str += "  <table align='center' id='table3' bgcolor='#999999' border='0' cellpadding='4' cellspacing='1'";
            str += "   width='100%'>";
            str += "   <tr>";
            str += "   <td align='center' bgcolor='#efefef' class='cpx12hei' colspan='3' width='33%' style='height: 21px'>";
            str += "      <b>奖励信息</b>";
            str += "   </td>";
            str += "   </tr>";
            str += "  <tr style='color: #E7E7FF; background-color: #4A3C8C; font-weight: bold; white-space: nowrap;'>";
            str += "  <th scope='col' style='color: DarkSlateGray; background-color: #94C3CE; white-space: nowrap;'>发生日期</th>";
            str += "  <th align='center' scope='col' style='color: DarkSlateGray; background-color: #94C3CE;white-space: nowrap;'>奖励原因</th>";
            str += "  <th align='center' scope='col' style='color: DarkSlateGray; background-color: #94C3CE;white-space: nowrap;'>奖励情况</th>";
            str += "   </tr>";
            str += " <tr style='color: Black; background-color: #FBFCFE;'>";
            str += "   <td style='white-space: nowrap;'>" + Convert.ToDateTime(dt.Rows[0]["PraiseTime"].ToString()).ToString("yyyy-MM-dd") + "</td>";
            str += "    <td style='white-space: nowrap;'>" + dt.Rows[0]["PraiseReason"].ToString() + "</td>";
            str += "  <td align='left' style='white-space: nowrap;'>" + dt.Rows[0]["PraiseContent"].ToString() + "</td>";
            str += "  </tr>";
            str += " </table>";
        }
        this.lblPraiseMessage.Text = str;
    }

    public void PublishMessage()
    {
        string str = "";
        DataTable dt = dal.GetPublishMessage(this.GongHao.Text, GetRequestStr("starttime"), GetRequestStr("endtime"));
        if (dt.Rows.Count > 0)
        {
            str += " <table align='center' id='table4' bgcolor='#999999' border='0' cellpadding='4' cellspacing='1'";
            str += " width='100%'>";
            str += "  <tr>";
            str += "  <td align='center' bgcolor='#efefef' class='cpx12hei' colspan='7' width='33%' style='height: 21px'>";
            str += "   <b>惩罚信息</b>";
            str += "  </td>";
            str += "  </tr>";
            str += "  <tr style='color: #E7E7FF; background-color: #4A3C8C; font-weight: bold; white-space: nowrap;'>";
            str += "   <th scope='col' style='color: DarkSlateGray; background-color: #94C3CE; white-space: nowrap;'>";
            str += "    发生日期";
            str += "  </th>";
            str += "  <th align='center' scope='col' style='color: DarkSlateGray; background-color: #94C3CE;white-space: nowrap;'>惩罚类别</th>";
            str += " <th align='center' scope='col' style='color: DarkSlateGray; background-color: #94C3CE;white-space: nowrap;'>惩罚项目</th>";
            str += " <th align='center' scope='col' style='color: DarkSlateGray; background-color: #94C3CE;white-space: nowrap;'>行政处分</th>";
            str += " <th align='center' scope='col' style='color: DarkSlateGray; background-color: #94C3CE;white-space: nowrap;'>党纪处分</th>";
            str += "  <th scope='col' style='color: DarkSlateGray; background-color: #94C3CE; white-space: nowrap;'>经济处罚</th>";
            str += "  <th scope='col' style='color: DarkSlateGray; background-color: #94C3CE; white-space: nowrap;'>处罚文号</th>";
            str += " </tr>";
            str += "  <tr style='color: Black; background-color: #FBFCFE;'>";
            str += "  <td style='white-space: nowrap;'>" + Convert.ToDateTime(dt.Rows[0]["PunishTime"].ToString()).ToString("yyyy-MM-dd") + "</td>";
            str += "  <td style='white-space: nowrap;'>" + dt.Rows[0]["Type"].ToString() + "</td>";
            str += "   <td align='left' style='white-space: nowrap;'>" + dt.Rows[0]["Project"].ToString() + "</td>";
            str += "    <td align='left' style='white-space: nowrap;'>" + dt.Rows[0]["XingZhengPunish"].ToString() + "</td>";
            str += "   <td style='white-space: nowrap;'>" + dt.Rows[0]["DangJiPunish"].ToString() + "</td>";
            str += "   <td align='left' style='white-space: nowrap;'>" + dt.Rows[0]["JingJiPunish"].ToString() + "</td>";
            str += "  <td align='left' style='white-space: nowrap;'>" + dt.Rows[0]["Code"].ToString() + "</td>";
            str += " </tr>";
            str += " </table>";
        }
        this.lblPublishMessage.Text = str;
    }

    private void BindList()
    {
    }

    protected void btnReturn_Click(object sender, EventArgs e)
    {
        Response.Redirect("UserMessages.aspx?islook=" + GetRequestStr("islook") + "");
    }

   
}
